package com.siruier.boss.ui.activity.order

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.flyco.tablayout.listener.OnTabSelectListener
import com.siruier.boss.R
import com.siruier.boss.databinding.ActivityGiftWarehouseOrderBinding
import com.siruier.boss.ui.base.BaseActivity
import com.siruier.boss.ui.ext.tabData
import com.siruier.boss.ui.fragment.order.GiftWarehouseReceiveFragment
import com.siruier.boss.ui.fragment.order.GiftWarehouseSendFragment
import com.siruier.boss.ui.helper.InjectBundle
import com.siruier.boss.ui.utils.FragmentChangeManager

class GiftWarehouseActivity : BaseActivity<ActivityGiftWarehouseOrderBinding>(), OnTabSelectListener {

    private var mFragmentChangeManager: FragmentChangeManager? = null
    private val index: Int by InjectBundle { 0 }
    private val indexReceive: Int by InjectBundle { 0 }
    override fun initView() {
        vb.tabLayout.setOnTabSelectListener(this)
        vb.tabLayout.tabData {
            tab("我送出的")
            tab("我收到的")
        }
        val fragments = ArrayList<Fragment>()
        fragments.add(GiftWarehouseSendFragment())
        fragments.add(GiftWarehouseReceiveFragment().apply {
            arguments = Bundle().apply {
                putInt("indexReceive", indexReceive)
            }
        })
        vb.tabLayout.currentTab = index
        mFragmentChangeManager = FragmentChangeManager(supportFragmentManager, R.id.frameLayout, fragments, index)
    }

    override fun onTabSelect(position: Int) {
        mFragmentChangeManager?.setFragments(position)
    }

    override fun onTabReselect(position: Int) {

    }
}